//
// Created by 龚任根 on 2020/8/8.
// Copyright (c) 2020 龚任根. All rights reserved.
//

#ifndef TEST_CPP_PROJECT_LIST_H
#define TEST_CPP_PROJECT_LIST_H

#include "iostream"

using namespace std;

template<class Type>
class List {

private:
    int max = 0;
    int currentIndex = 0;
    Type *arr;

public:
    List(int maxSize)
            : max(maxSize), currentIndex(0) {
        arr = (Type *) malloc(maxSize * sizeof(Type));
    }

    ~List() {
        delete arr;
    }

    inline
    const Type get(int position) const {
        return arr[position];
    }

    inline
    void add(Type &type) {
        if (currentIndex >= max) {
            return;
        }
        arr[currentIndex++] = type;
    }

    inline
    int const maxSize() {
        return max;
    }

    inline
    int const size() {
        return currentIndex;
    }

};


#endif //TEST_CPP_PROJECT_LIST_H
